<%@ page import="java.util.*, SiTuQingYou.vo.*"  language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%String path=request.getContextPath(); %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style type="text/css">
#article
{
 
 
margin-top:20px;
}
#titlex
{
 
margin-top:40px;
text-align: center;
border-bottom: 2px solid gray;
}
#bo
{
margin-top:20px;


margin-left:0px;
}
#title
{
width:800px;
}
.but
{
 float:right;
 margin-top:30px;
 height:40px;
 background-color:#FF8000;
 color:white;
 width:100px;
 display:inline-block;
 cursor: pointer;
 border: none;
 border-radius: 5px;
 font-family: fantasy;
 font-size: 15px;
}
.but:hover
{
 background-color:#FFD700;
}
</style>
  <script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>
  <script type="text/javascript">
  $(document).ready(function(){
	  $("#city").change(function(){
		  $("#scene").html("<option>请选择景点</option>"); 
		  var id=$("#city").val();
		  $.ajax({
			  url:"<%=path%>/GetCitySceneByCityIdServlet",
			  type:"post",
			  data:"method=getcityscenebycity&id="+id,
			  success:function(mes){
				  var str = mes; //这是一字符串 
					var n=str.indexOf(".");
					var m=n+1;
					var strid=str.substring(m);
					var sceneid=new Array();
					sceneid=strid.split(".");
					var strx=str.substring(1,n);
					var scenes = new Array(); //定义一数组
					scenes = strx.split(","); //字符分割 
					for(var i=0;i<scenes.length;i++)
					{
					var op=$("<option></option>");
					var x=scenes[i];
					var y=sceneid[i];
					op.html(x);
					op.val(y);
					$("#scene").append(op);
			  		}
			  }
			  });
	  });
  });
  
  </script>
  
  <script type="text/javascript">
  $(document).ready(load);
  function load()
  {
  	 
  	$("#title").blur(checkTitle);
  	$("#scene").change(checkScene);
  	$("#cover").change(checkCover);
  	$("#content").blur(checkContent);
  }
  
  function checkTitle()
  {
	  var scene=$("#title").val();
	  var zz=/^\S{1,50}$/;
	  var flag=zz.test(scene);
	  if(flag==true)
		  {
		  return true;
		  }
	  else
		  {
		  return false;
		  }
  }
  
  function checkScene()
  {
	  var scene=$("#scene").val();
	  var str="请选择景点";
	  
	  if(scene!=str)
		  {
		  return true;
		  }
	  else
		  {
		  return false;
		  }
  }
  function checkCover()
  {
	  var cover=$("#cover").val();
		  if( cover!="")
		  {
		  return true;
		  }
	  else
		  {
		  return false;
		  }
  }
  function checkContent()
  {
	 
  	var content=UE.getEditor('content').getContentTxt();
  	var zz=/^[\s\S]{50,}$/;
  	var flag=zz.test(content);
  	if(flag==true)
  		{
  		return true;
  		}
  	else
  		{
  		return false;
  		}
  	
  }
  </script>
  <script type="text/javascript">
  function a()
  {
	  return true;
  }
  $(document).ready(function(){
	  $("#formx").submit(check);
  });
  function check()
  {
	  var ct=checkTitle();
	  var cs=checkScene();
	  var cc=checkContent();
	  var ccov=checkCover();
	  if(ct&&cs&&cc&&ccov)
		  {
		  alert("提交成功！")
		  return true;
		  }
	  else
		  {
		  alert("请按规定将信息补充完整！");
		  return false;
		  }
	   
  }
  
  </script>
</head>
<body>
<jsp:include page="header.jsp"></jsp:include>
<div id="article">
<div id="titlex"><h2>我的攻略</h2></div>
<div id="bo">
<form id="formx" enctype="multipart/form-data" action="<%=path%>/StrategyServlet?method=writeStrategy" method="post">
		<fieldset>
		<jsp:include page="/GetCitySceneByCityIdServlet"><jsp:param value="getAllCity" name="method"/></jsp:include>
			<label>景点选择：</label>
			<select id="city">
			<option>请选择城市</option>
			<%
			ArrayList<City> citys=(ArrayList<City>)request.getAttribute("citys");
			for(int i=0;i<citys.size();i++)
			{
				%>
				<option value="<%=citys.get(i).getId()%>"><%=citys.get(i).getCityname() %></option>
				<% 
			}
			 
			%>
			</select>
			<select name="sceneid" id="scene">
			<option>请选择景点</option>
			</select>
		</fieldset>
		<fieldset>
			<label>标题(不超过50个字符)：</label>
			<input type="text" name="title" id="title" >
		</fieldset>
		<fieldset>
			<label>封面图片：</label>
			<input id="cover" name="cover" type="file" >
		</fieldset>
	 <fieldset>
	 	<label>正文(不少于50个字符)：</label>
	 	<textarea  name="content" id="content" ></textarea>
	 </fieldset>
	 <fieldset>
	 	<input class="but" type="submit" value="提交" >
	 	<input class="but" type="reset" value="重置" >
	 </fieldset>
	</form>
</div>
</article> 
	<!-- 配置文件 -->
 <script type="text/javascript" src="<%=path %>/js/ueditor.config.js?123123"></script>
 <!-- 编辑器源码文件 -->
 <script type="text/javascript" src="<%=path %>/js/ueditor.all.js"></script>
 <!-- 实例化编辑器 -->
 <script type="text/javascript">
     var ue = UE.getEditor('content');
 </script>
</div>
<jsp:include page="footer.jsp"></jsp:include>
</body>
</html>